package org.com.yz.dubbo.web.ctrl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringEscapeUtils;
import org.com.yz.common.annotion.Parameter;
import org.com.yz.common.constant.PayConstant;
import org.com.yz.common.util.ClassRefUtil;
import org.com.yz.dal.dao.model.BatchCreateMchSubEs;
import org.com.yz.dubbo.api.service.IBankCardService;
import org.com.yz.dubbo.web.service.CheckMchAccntService;
import org.com.yz.dubbo.web.service.RpcCommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 批量开设子商户控制类
 *
 * ClassName BatchCreateMchSubCtr
 * Author wzc
 * Date 2018/7/24 9:25
 **/
@RestController
public class BatchCreateMchSubCtr {

    @Reference(version = "1.0.0", timeout = 30000, retries = -1)
    public IBankCardService bankCardService;

    @Autowired
    private RpcCommonService rpcCommonService;

    @Autowired
    private CheckMchAccntService checkMchAccntService;


    /**
     * @param data,sign
     * @Description: 批量开设子商户
     * @author wzc
     * @date 2018/7/24 9:26
     */
    @PostMapping(value = "/api/batchCreateMchSub.htm")
    @Parameter
    public String batchCreateMchSub(String data, String sign) {

        BatchCreateMchSubEs subEs = JSONObject.parseObject(StringEscapeUtils.unescapeJava(data), BatchCreateMchSubEs.class);

        BatchCreateMchSubEs res = new BatchCreateMchSubEs();
        try {
            res = rpcCommonService.bathCreateMchSubService.bathCreateMchSubHandel(subEs);
        } catch (Exception e) {
            res.setBizContent(null);
            return ClassRefUtil.createRetData(subEs, res, PayConstant.RETURN_DEPOSIT_CODE_ERROR, PayConstant.RETURN_DEPOSIT_CODES_ERROR);
        }
        return ClassRefUtil.createRetData(subEs, res, PayConstant.RETURN_DEPOSIT_SUCESS, PayConstant.RETURN_ALIPAY_VALUE_SUCCESS);
    }
}
